/*
 * 全局头部 和 一级菜单
 * */

import { IRouteComponentProps } from 'umi';
import * as React from 'react';
import { Fragment } from 'react';

import PageLoading from '@/components/PageLoading/loading';
import styles from './basisLayouts.less';
import { connect } from 'umi';
import { ConnectState, Loading } from '@/models/connect';

interface Props extends IRouteComponentProps {
  loading: Loading;
  test?: string;
}

const Layout = (props: Props) => {
  const { loading, children } = props;

  let loadingValue = loading.global;
  // 过滤掉非Loading请求。
  if (loading.effects['searchModels/getRecommendList']) {
    loadingValue = false;
  }
  return (
    <Fragment>
      {loadingValue && <PageLoading />}
      <div className={styles.layoutsList}>{children}</div>
    </Fragment>
  );
};

export default connect(({ loading }: ConnectState) => ({
  loading,
}))(Layout);
